package io.renren.modules.personnel.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.personnel.entity.InterviewPassdListEntity;
import io.renren.modules.personnel.service.InterviewPassdListService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 面试通过名单
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2022-01-02 18:21:01
 */
@RestController
@RequestMapping("personnel/interviewpassdlist")
public class InterviewPassdListController {
    @Autowired
    private InterviewPassdListService interviewPassdListService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("personnel:interviewpassdlist:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = interviewPassdListService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{interviewId}")
    @RequiresPermissions("personnel:interviewpassdlist:info")
    public R info(@PathVariable("interviewId") Long interviewId){
        InterviewPassdListEntity interviewPassdList = interviewPassdListService.getById(interviewId);

        return R.ok().put("interviewPassdList", interviewPassdList);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("personnel:interviewpassdlist:save")
    public R save(@RequestBody InterviewPassdListEntity interviewPassdList){
        interviewPassdListService.save(interviewPassdList);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("personnel:interviewpassdlist:update")
    public R update(@RequestBody InterviewPassdListEntity interviewPassdList){
        ValidatorUtils.validateEntity(interviewPassdList);
        interviewPassdListService.updateById(interviewPassdList);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("personnel:interviewpassdlist:delete")
    public R delete(@RequestBody Long[] interviewIds){
        interviewPassdListService.removeByIds(Arrays.asList(interviewIds));

        return R.ok();
    }

}
